﻿using Lufei_CaterDAL;
using Lufei_CaterModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lufei_CaterBLL
{
    public class RoomInfoBLL
    {

        RoomDAL dal = new RoomDAL();


        /// <summary>
        /// 查询所有没有被删除的房间
        /// </summary>
        /// <returns></returns>
        public List<RoomInfo> GetRoomsByDelFlag()
        {
            return dal.GetRoomsByDelFlag();
        }

        /// <summary>
        /// 添加房间
        /// </summary>
        /// <returns></returns>
        public bool InserRoom(RoomInfo ri)
        { 
            return dal.InserRoom(ri)>0;
        }


        /// <summary>
        /// 删除房间
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteRoom(int id)
        {
            return dal.DeleteRoom(id)>0;
        }


        /// <summary>
        /// 根据id获取房间
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RoomInfo GetRoomByID(int id)
        {

            return dal.GetRoomByID(id);
        }


        /// <summary>
        /// 修改房间
        /// </summary>
        /// <returns></returns>
        public bool UpdateRoomById(RoomInfo ri)
        {
            return dal.UpdateRoomById(ri)>0;
        }


        /// <summary>
        /// 查询所有房间姓名
        /// </summary>
        /// <returns></returns>
        public List<string> GetRoomsName()
        {
            List<RoomInfo> list= dal.GetRoomsByDelFlag();
            List<string> roomName = new List<string>();
            foreach (var item in list)
            {
                roomName.Add(item.RoomName);
            }
            return roomName;
        }

    }
}
